home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / cfb / cfbpolypnt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-15  |  3.7 KB  |  154 lines

  1. /************************************************************
  2. Copyright 1989 by The Massachusetts Institute of Technology
  3.  
  4. Permission to use, copy, modify, and distribute this
  5. software and its documentation for any purpose and without
  6. fee is hereby granted, provided that the above copyright
  7. no- tice appear in all copies and that both that copyright
  8. no- tice and this permission notice appear in supporting
  9. docu- mentation, and that the name of MIT not be used in
  10. advertising or publicity pertaining to distribution of the
  11. software without specific prior written permission.
  12. M.I.T. makes no representation about the suitability of
  13. this software for any purpose. It is provided "as is"
  14. without any express or implied warranty.
  15.  
  16. ********************************************************/
  17.  
  18. /* $XConsortium: cfbpolypnt.c,v 5.8 89/11/25 14:55:28 rws Exp $ */
  19.  
  20. #include "X.h"
  21. #include "gcstruct.h"
  22. #include "windowstr.h"
  23. #include "pixmapstr.h"
  24. #include "regionstr.h"
  25. #include "scrnintstr.h"
  26. #include "cfb.h"
  27. #include "cfbmskbits.h"
  28.  
  29. void
  30. cfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
  31.     DrawablePtr pDrawable;
  32.     GCPtr pGC;
  33.     int mode;
  34.     int npt;
  35.     xPoint *pptInit;
  36. {
  37.     register int *addr;
  38.     register xPoint *ppt;
  39.     RegionPtr cclip;
  40.     int nbox;
  41.     register int x, y;
  42.     register int i;
  43.     int *addrl;
  44.     register int nlwidth;
  45.     register BoxPtr pbox;
  46.     int rop = pGC->alu;
  47.     unsigned long pixel = pGC->fgPixel;
  48.     unsigned long planemask = PFILL(pGC->planemask);
  49.     unsigned long mask;
  50.     register int x1, x2, y1, y2;
  51.     register int xoff, yoff;
  52.  
  53.     if (!planemask)
  54.     return;
  55.     if ((mode == CoordModePrevious) && (npt > 1))
  56.     {
  57.     for (ppt = pptInit + 1, i = npt - 1; --i >= 0; ppt++)
  58.     {
  59.         ppt->x += (ppt-1)->x;
  60.         ppt->y += (ppt-1)->y;
  61.     }
  62.     }
  63.     cclip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
  64.     if (pDrawable->type == DRAWABLE_WINDOW)
  65.     {
  66.     addrl = (int *)
  67.         (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr);
  68.     nlwidth = (int)
  69.         (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind);
  70.     }
  71.     else
  72.     {
  73.     addrl = (int *)(((PixmapPtr)pDrawable)->devPrivate.ptr);
  74.     nlwidth = (int)(((PixmapPtr)pDrawable)->devKind);
  75.     }
  76.     xoff = pDrawable->x;
  77.     yoff = pDrawable->y;
  78. #if PPW == 4
  79.     if ((rop == GXcopy) && ((planemask & PMSK) == PMSK))
  80.     {
  81.     addr = addrl;
  82.     if (!(nlwidth & (nlwidth - 1)))
  83.     {
  84.         nlwidth = ffs(nlwidth) - 1;
  85.         for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip);
  86.          --nbox >= 0;
  87.          pbox++)
  88.         {
  89.         x1 = pbox->x1;
  90.         y1 = pbox->y1;
  91.         x2 = pbox->x2;
  92.         y2 = pbox->y2;
  93.         for (ppt = pptInit, i = npt; --i >= 0; ppt++)
  94.         {
  95.             x = ppt->x + xoff;
  96.             y = ppt->y + yoff;
  97.             if ((x >= x1) && (x < x2) &&
  98.             (y >= y1) && (y < y2))
  99.             {
  100.             *((char *)(addr) + (y << nlwidth) + x) = pixel;
  101.             }
  102.         }
  103.         }
  104.     }
  105.     else
  106.     {
  107.         for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip);
  108.          --nbox >= 0;
  109.          pbox++)
  110.         {
  111.         x1 = pbox->x1;
  112.         y1 = pbox->y1;
  113.         x2 = pbox->x2;
  114.         y2 = pbox->y2;
  115.         for (ppt = pptInit, i = npt; --i >= 0; ppt++)
  116.         {
  117.             x = ppt->x + xoff;
  118.             y = ppt->y + yoff;
  119.             if ((x >= x1) && (x < x2) &&
  120.             (y >= y1) && (y < y2))
  121.             {
  122.             *((char *)(addr) + (y * nlwidth) + x) = pixel;
  123.             }
  124.         }
  125.         }
  126.     }
  127.     return;
  128.     }
  129. #endif
  130.     nlwidth >>= 2;
  131.     pixel = PFILL(pixel);
  132.     for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip);
  133.      --nbox >= 0;
  134.      pbox++)
  135.     {
  136.     x1 = pbox->x1;
  137.     y1 = pbox->y1;
  138.     x2 = pbox->x2;
  139.     y2 = pbox->y2;
  140.     for (ppt = pptInit, i = npt; --i >= 0; ppt++)
  141.     {
  142.         x = ppt->x + xoff;
  143.         y = ppt->y + yoff;
  144.         if ((x >= x1) && (x < x2) &&
  145.         (y >= y1) && (y < y2))
  146.         {
  147.         addr = addrl + (y * nlwidth) + (x >> PWSH);
  148.         mask = cfbmask[x & PIM] & planemask;
  149.         *addr = (*addr & ~mask) | (DoRop(rop, pixel, *addr) & mask);
  150.         }
  151.     }
  152.     }
  153. }
  154.